<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #25262f;
            color: #fff;
        }

        .dashboard {
            display: grid;
            grid-template-columns: 2fr 3fr 2fr;
            /* grid-template-rows: repeat(3, 1fr); */
            gap: 10px;
            padding: 20px;
        }

        .dashboard-header div:last-child {
            font-size: 16px;
            align-self: flex-end;
        }

        .dashboard-header {
            height: 80px;
            color: #fff;
            font-size: 34px;
            font-weight: bold;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 90px 10px;
        }

        .sales-trend {
            background: #33475b;
            padding: 5px;
            border-radius: 8px;
        }

        h2 {
            font-size: 18px;
        }

        .chart {
            background: #2a3b4c;
            height: 200px;
            border-radius: 8px;
        }

        .left {
            display: flex;
            flex-direction: column;
        }

        .left div {
            margin-bottom: 10px;
        }

        .left .chart {
            height: 280px;
        }

        .center .chart {
            display: flex;
            flex-direction: column;
            height: 600px;
        }

        .center .chart .top {
            flex: 1.5;
        }

        .center .chart .bottom {
            flex: 1;
        }
    </style>
</head>

<body>
    <div class="dashboard-header">
        <div><img src="http://8.138.119.204:8081/static/img/logo1.png" alt=""></div>
        <div>电商平台实时监控系统</div>
        <div>2024-12-21 17:59:20</div>
    </div>
    <div class="dashboard">
        <div class="left">
            <div class="sales-trend">
                <div class="chart">图表占位符</div>
            </div>
            <div class="sales-trend">
                <div class="chart">图表占位符</div>
            </div>
        </div>

        <div class="center">
            <div class="sales-trend">
                <div class="chart">
                    <div class="top">
                        图表占位符
                    </div>
                    <div class="bottom">
                        图表占位符
                    </div>
                </div>
            </div>
        </div>

        <div class="left">
            <div class="sales-trend">
                <div class="chart">图表占位符</div>
            </div>
            <div class="sales-trend">
                <div class="chart">图表占位符</div>
            </div>
        </div>


    </div>
    <script src='lib/axios.js'></script>
    <script src="lib/echats.js"></script>
    <script>

        // 给五个盒子设定id及相关数据
        function setBox() {
            let i = 1
            document.querySelectorAll('.sales-trend').forEach((item) => {
                item.id = `main${i++}`
                item.style.height = '100%';
                item.style.width = '100%';
                item.style.paddingBottom = ''

            })
        }

        // 获取所有接口的数据数组
        async function getData() {
            let axiosArr = [
                axios({ url: "http://8.138.119.204:8182/api/trend?type=map" }),  // 折线图数据
                axios({ url: "http://8.138.119.204:8182/api/seller" }),          // 横向柱数据
                axios({ url: "http://8.138.119.204:8182/api/points" }),          // 分布点数据
                axios({ url: "http://8.138.119.204:8182/api/rank" }),            // 柱状图数据
                axios({ url: "http://8.138.119.204:8182/api/commodity" }),       // 饼状图数据
                axios({ url: "http://8.138.119.204:8182/api/stock" })            // 仪表盘数据
            ]

            // 拿到相应数据取出数据数组(响应失败返回空对象)
            let resArr = await Promise.allSettled(axiosArr)
            let dataArr = resArr.map(item => {
                if (item.status === "fulfilled") {
                    return item.value.data.data
                } else return null
            })
            // console.log(dataArr);

            // 传出数据数组
            return dataArr
        }

        setBox()
    </script>
    <!-- 销售趋势 -->
    <script src='js/sales-trend.js'></script>
    <!-- 销量统计 -->
    <script src='js/sales-statistics.js'></script>
    <!-- 分布排行 -->
    <script src='js/sales-distribution-ranking.js'></script>
    <!-- 热销占比 -->
    <script src='js/hot-sales.js'></script>
    <!-- 库存销量 -->
    <script src='js/inventory-sales.js'></script>
</body>

</html>